package gang.org.springframework.framework.beans;

import gang.org.springframework.framework.util.GangObjectUtils;

/**
 * @author gang.chen
 * @Date 2021/8/26 8:09
 */
public abstract class GangAbstractNestablePropertyAccessor {

    public Object wrappedObject;

    public Object rootObject;

    private String nestedPath = "";

    //TODO
    protected GangAbstractNestablePropertyAccessor(Object object){
        //registerDefaultEditors()
        setWrappedInstance(object);
    }
    //TODO
    public void setWrappedInstance(Object object){
        setWrappedInstance(object,"",null);
    }
    //TODO
    public void setWrappedInstance(Object object, String nestedPath, Object rootObject){
        this.wrappedObject = GangObjectUtils.unwrapOptional(object);
        this.nestedPath = nestedPath != null? nestedPath: "";
        this.rootObject = !this.nestedPath.isEmpty() ? rootObject : this.wrappedObject;

        //TODO 其它业务暂不处理
    }

    //TODO
    public GangAbstractNestablePropertyAccessor(boolean registerDefaultEditors){

    }

    public final Object getWrappedInstance(){
        return this.wrappedObject;
    }
}
